package com.learn.flyweight;

import com.learn.flyweight.base.Chessman;
import com.learn.flyweight.base.ChessmanFactory;
import com.learn.flyweight.other.OtherChessman;
import com.learn.flyweight.other.OtherChessmanFactory;
import com.learn.flyweight.other.Position;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>项目名称: design-pattern </p>
 *
 * <p>文件名称: App </p>
 *
 * <p>描述: TODO </p>
 */
@Slf4j
public class App {

    public static void main(String[] args) {
        Chessman black1,black2,black3,white1,white2;
        black1 = ChessmanFactory.getInstance().getChessman(Color.BLACK);
        black2 = ChessmanFactory.getInstance().getChessman(Color.BLACK);
        black3 = ChessmanFactory.getInstance().getChessman(Color.BLACK);
        white1 = ChessmanFactory.getInstance().getChessman(Color.WHITE);
        white2 = ChessmanFactory.getInstance().getChessman(Color.WHITE);

        black1.display();
        black2.display();
        black3.display();
        white1.display();
        white2.display();

        log.info("black1和black2是否相同：{}",black1.equals(black2));
        log.info("black1和black3是否相同：{}",black1.equals(black3));
        log.info("white1和white2是否相同：{}",white1.equals(white2));

        log.info("---------------------------------------------",white1.equals(white2));

        OtherChessman ob1,ob2,ow1,ow2;
        ob1 = OtherChessmanFactory.getInstance().getChessman(Color.WHITE);
        ob2 = OtherChessmanFactory.getInstance().getChessman(Color.WHITE);
        ow1 = OtherChessmanFactory.getInstance().getChessman(Color.WHITE);
        ow2 = OtherChessmanFactory.getInstance().getChessman(Color.WHITE);

        ob1.display(new Position(1,1));
        ob2.display(new Position(1,3));
        ow1.display(new Position(2,5));
        ow2.display(new Position(3,1));
    }
}
